// Copyright © 2025 The Things Network Foundation, The Things Industries B.V.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import React, { useCallback, useMemo, useState } from 'react'
import { get, set, isEmpty, omitBy } from 'lodash'
import { useDispatch } from 'react-redux'
import { useLocation, useNavigate, useParams } from 'react-router-dom'
import { defineMessages } from 'react-intl'

import Form, { useFormContext } from '@ttn-lw/components/form'
import Radio from '@ttn-lw/components/radio-button'
import Input from '@ttn-lw/components/input'
import Checkbox from '@ttn-lw/components/checkbox'
import UnitInput from '@ttn-lw/components/unit-input'
import Select from '@ttn-lw/components/select'
import KeyValueMap from '@ttn-lw/components/key-value-map'
import Icon, { IconPlus, IconTrash } from '@ttn-lw/components/icon'
import Button from '@ttn-lw/components/button'
import SubmitBar from '@ttn-lw/components/submit-bar'
import SubmitButton from '@ttn-lw/components/submit-button'
import toast from '@ttn-lw/components/toast'

import Message from '@ttn-lw/lib/components/message'

import sharedMessages from '@ttn-lw/lib/shared-messages'
import tooltipIds from '@ttn-lw/lib/constants/tooltip-ids'
import attachPromise from '@ttn-lw/lib/store/actions/attach-promise'
import PropTypes from '@ttn-lw/lib/prop-types'
import diff from '@ttn-lw/lib/diff'

import { FRAME_WIDTH_COUNT, fCntWidthEncode, fCntWidthDecode } from '@console/lib/device-utils'
import {
  maxDutyCycleOptions,
  pingSlotPeriodicityOptions,
  adrAckLimitOptions,
  adrAckDelayOptions,
} from '@console/lib/mac-settings-utils'

import {
  createMacSettingsProfile,
  updateMacSettingsProfile,
} from '@console/store/actions/mac-settings-profiles'

import { validationSchema, initialValues } from './form-validation'

const m = defineMessages({
  updated: 'MAC settings profile updated',
  created: 'MAC settings profile created',
})

// 0...15
const dataRateOverrideOptions = Array.from({ length: 16 }, (_, index) => ({
  value: `data_rate_${index}`,
  label: <Message content={sharedMessages.dataRate} values={{ n: index }} />,
}))

const MACSettingsProfileInnerForm = ({ edit }) => {
  const { values, setFieldValue, setFieldTouched } = useFormContext()
  const { mac_settings } = values
  const [resetsFCnt, setResetsFCnt] = useState(false)
  const handleResetsFCntChange = useCallback(evt => {
    const { checked } = evt.target

    setResetsFCnt(checked)
  }, [])

  const isDynamicAdr = mac_settings?.adr && 'dynamic' in mac_settings?.adr
  const isStaticAdr = mac_settings?.adr && 'static' in mac_settings?.adr
  const adrOverrides = mac_settings?.adr?.dynamic?.overrides
  const showEditNbTrans = !values.mac_settings?.adr?.dynamic?._use_default_nb_trans
  const defaultNbTransDisabled = !values.mac_settings?.adr?.dynamic?._override_nb_trans_defaults
  const addOverride = useCallback(() => {
    const newOverride = { _data_rate_index: '', min_nb_trans: '', max_nb_trans: '' }
    setFieldValue(
      'mac_settings.adr.dynamic.overrides',
      adrOverrides
        ? { ...adrOverrides, [`_empty-${Date.now()}`]: newOverride }
        : { [`_empty-${Date.now()}`]: newOverride },
    )
    setFieldTouched('mac_settings.adr.dynamic._overrides', true)
  }, [setFieldValue, adrOverrides, setFieldTouched])
  const handleRemoveButtonClick = useCallback(
    (_, index) => {
      setFieldValue(
        'mac_settings.adr.dynamic.overrides',
        Object.keys(adrOverrides)
          .filter(key => key !== index)
          .reduce((acc, key) => ({ ...acc, [key]: adrOverrides[key] }), {}),
      )
    },
    [adrOverrides, setFieldValue],
  )

  // Define a value setter for the data rate index field which
  // handles setting the object keys correctly, since the index
  // is set as the object key in the API schema.
  // A similar result could be done without pseudo values, purely
  // with decoder/encoder, but it would make error mapping
  // more complex.
  const dataRateValueSetter = useCallback(
    ({ setValues }, { name, value }) => {
      const index = name.split('.').slice(-2)[0] // Would be: data_rate_{x}.
      const oldOverride = get(values, `mac_settings.adr.dynamic.overrides.${index}`, {})
      const overrides = { ...get(values, 'mac_settings.adr.dynamic.overrides', {}) }
      // Empty data rate index objects, are stored with a pseudo key. Remove it.
      delete overrides[index]
      // Move the existing values to the new data rate key.
      overrides[value] = { ...oldOverride, _data_rate_index: value }
      setValues(values => set(values, 'mac_settings.adr.dynamic.overrides', overrides))
    },
    [values],
  )

  const getEncodedAdrModeValue = useCallback(mode => {
    if (mode === 'static') {
      return {
        data_rate_index: 0,
        tx_power_index: 0,
        nb_trans: 1,
      }
    }
    return {}
  }, [])

  const encodeAdrMode = value => ({ [value]: getEncodedAdrModeValue(value) })
  const decodeAdrMode = value => (value !== undefined ? Object.keys(value)[0] : null)

  return (
    <>
      <Form.Field
        title={sharedMessages.profileId}
        name="ids.profile_id"
        component={Input}
        required
        fieldWidth="half"
        disabled={edit}
      />
      <Form.Field
        title={sharedMessages.frameCounterWidth}
        name="mac_settings.supports_32_bit_f_cnt"
        component={Radio.Group}
        encode={fCntWidthEncode}
        decode={fCntWidthDecode}
        tooltipId={tooltipIds.FRAME_COUNTER_WIDTH}
        horizontal
      >
        <Radio label={sharedMessages['16Bit']} value={FRAME_WIDTH_COUNT.SUPPORTS_16_BIT} />
        <Radio label={sharedMessages['32Bit']} value={FRAME_WIDTH_COUNT.SUPPORTS_32_BIT} />
      </Form.Field>
      <Form.FieldContainer horizontal>
        <Form.Field
          title={sharedMessages.rx1Delay}
          type="number"
          tooltipId={tooltipIds.RX1_DELAY}
          append={<Message content={sharedMessages.secondsAbbreviated} />}
          name="mac_settings.rx1_delay"
          component={Input}
          min={1}
          max={15}
          fieldWidth="half"
        />
        <Form.Field
          title={sharedMessages.desiredRx1DelayTitle}
          type="number"
          name="mac_settings.desired_rx1_delay"
          append={<Message content={sharedMessages.secondsAbbreviated} />}
          tooltipId={tooltipIds.RX1_DELAY}
          component={Input}
          min={1}
          max={15}
          fieldWidth="half"
        />
      </Form.FieldContainer>
      <Form.FieldContainer horizontal>
        <Form.Field
          title={sharedMessages.rx1DataRateOffset}
          type="number"
          name="mac_settings.rx1_data_rate_offset"
          component={Input}
          min={0}
          max={7}
          tooltipId={tooltipIds.DATA_RATE_OFFSET}
          fieldWidth="half"
        />
        <Form.Field
          title={sharedMessages.desiredRx1DataRateOffsetTitle}
          type="number"
          name="mac_settings.desired_rx1_data_rate_offset"
          component={Input}
          min={0}
          max={7}
          tooltipId={tooltipIds.DATA_RATE_OFFSET}
          fieldWidth="half"
        />
      </Form.FieldContainer>
      <Form.Field
        label={sharedMessages.resetsFCnt}
        onChange={handleResetsFCntChange}
        warning={resetsFCnt ? sharedMessages.resetFCntWarning : undefined}
        name="mac_settings.resets_f_cnt"
        tooltipId={tooltipIds.RESETS_F_CNT}
        component={Checkbox}
        fieldWidth="half"
      />
      <Form.FieldContainer horizontal>
        <Form.Field
          title={sharedMessages.rx2DataRateIndexTitle}
          type="number"
          name="mac_settings.rx2_data_rate_index"
          component={Input}
          min={0}
          max={15}
          tooltipId={tooltipIds.RX2_DATA_RATE_INDEX}
          fieldWidth="half"
        />
        <Form.Field
          title={sharedMessages.desiredRx2DataRateIndexTitle}
          type="number"
          name="mac_settings.desired_rx2_data_rate_index"
          component={Input}
          min={0}
          max={15}
          tooltipId={tooltipIds.RX2_DATA_RATE_INDEX}
          fieldWidth="half"
        />
      </Form.FieldContainer>
      <Form.FieldContainer horizontal>
        <Form.Field
          type="number"
          min={100000}
          step={100}
          title={sharedMessages.rx2Frequency}
          name="mac_settings.rx2_frequency"
          component={UnitInput.Hertz}
          tooltipId={tooltipIds.RX2_FREQUENCY}
          fieldWidth="half"
        />
        <Form.Field
          type="number"
          min={100000}
          step={100}
          title={sharedMessages.desiredRx2FrequencyTitle}
          name="mac_settings.desired_rx2_frequency"
          component={UnitInput.Hertz}
          tooltipId={tooltipIds.RX2_FREQUENCY}
          fieldWidth="half"
        />
      </Form.FieldContainer>
      <Form.FieldContainer horizontal>
        <Form.Field
          title={sharedMessages.maxDutyCycle}
          name="mac_settings.max_duty_cycle"
          component={Select}
          options={maxDutyCycleOptions}
          tooltipId={tooltipIds.MAX_DUTY_CYCLE}
          fieldWidth="half"
        />
        <Form.Field
          title={sharedMessages.desiredMaxDutyCycle}
          name="mac_settings.desired_max_duty_cycle"
          component={Select}
          options={maxDutyCycleOptions}
          tooltipId={tooltipIds.MAX_DUTY_CYCLE}
          fieldWidth="half"
        />
      </Form.FieldContainer>
      <Form.Field
        indexAsKey
        name="mac_settings.factory_preset_frequencies"
        component={KeyValueMap}
        title={sharedMessages.factoryPresetFrequencies}
        description={sharedMessages.factoryPresetFreqDescription}
        addMessage={sharedMessages.freqAdd}
        valuePlaceholder={sharedMessages.frequencyPlaceholder}
        tooltipId={tooltipIds.FACTORY_PRESET_FREQUENCIES}
        fieldWidth="half"
        className="flex-grow"
      />
      <Form.Field
        title={sharedMessages.classCTimeout}
        name="mac_settings.class_c_timeout"
        tooltipId={tooltipIds.CLASS_C_TIMEOUT}
        component={UnitInput.Duration}
        unitSelector={['ms', 's']}
        type="number"
        fieldWidth="half"
        selectWidth="full"
      />
      <Form.Field
        title={sharedMessages.classBTimeout}
        name="mac_settings.class_b_timeout"
        tooltipId={tooltipIds.CLASS_B_TIMEOUT}
        component={UnitInput.Duration}
        unitSelector={['ms', 's']}
        type="number"
        fieldWidth="half"
        selectWidth="full"
      />
      <Form.Field
        title={sharedMessages.pingSlotPeriodicity}
        description={sharedMessages.pingSlotPeriodicityDescription}
        name="mac_settings.ping_slot_periodicity"
        component={Select}
        options={pingSlotPeriodicityOptions}
        menuPlacement="top"
        fieldWidth="half"
      />
      <Form.FieldContainer horizontal>
        <Form.Field
          type="number"
          min={100000}
          title={sharedMessages.beaconFrequency}
          placeholder={sharedMessages.frequencyPlaceholder}
          name="mac_settings.beacon_frequency"
          tooltipId={tooltipIds.BEACON_FREQUENCY}
          component={UnitInput.Hertz}
          fieldWidth="half"
        />
        <Form.Field
          type="number"
          min={100000}
          title={sharedMessages.desiredBeaconFrequency}
          placeholder={sharedMessages.frequencyPlaceholder}
          name="mac_settings.desired_beacon_frequency"
          tooltipId={tooltipIds.BEACON_FREQUENCY}
          component={UnitInput.Hertz}
          fieldWidth="half"
        />
      </Form.FieldContainer>
      <Form.FieldContainer horizontal>
        <Form.Field
          type="number"
          min={100000}
          step={100}
          title={sharedMessages.pingSlotFrequency}
          placeholder={sharedMessages.frequencyPlaceholder}
          name="mac_settings.ping_slot_frequency"
          tooltipId={tooltipIds.PING_SLOT_FREQUENCY}
          component={UnitInput.Hertz}
          fieldWidth="half"
        />
        <Form.Field
          type="number"
          min={100000}
          step={100}
          title={sharedMessages.desiredPingSlotFrequencyTitle}
          placeholder={sharedMessages.frequencyPlaceholder}
          name="mac_settings.desired_ping_slot_frequency"
          tooltipId={tooltipIds.PING_SLOT_FREQUENCY}
          component={UnitInput.Hertz}
          fieldWidth="half"
        />
      </Form.FieldContainer>
      <Form.FieldContainer horizontal>
        <Form.Field
          title={sharedMessages.pingSlotDataRateTitle}
          name="mac_settings.ping_slot_data_rate_index"
          tooltipId={tooltipIds.PING_SLOT_DATA_RATE_INDEX}
          component={Input}
          type="number"
          min={0}
          max={15}
          fieldWidth="half"
        />
        <Form.Field
          title={sharedMessages.desiredPingSlotDataRateTitle}
          name="mac_settings.desired_ping_slot_data_rate_index"
          tooltipId={tooltipIds.PING_SLOT_DATA_RATE_INDEX}
          component={Input}
          type="number"
          min={0}
          max={15}
          fieldWidth="half"
        />
      </Form.FieldContainer>
      <Form.FieldContainer horizontal>
        <Form.Field
          title={sharedMessages.statusCountPeriodicity}
          name="mac_settings.status_count_periodicity"
          component={Input}
          append={<Message content={sharedMessages.messages} />}
          type="number"
          tooltipId={tooltipIds.STATUS_COUNT_PERIODICITY}
          fieldWidth="half"
        />
        <Form.Field
          title={sharedMessages.statusTimePeriodicity}
          name="mac_settings.status_time_periodicity"
          component={UnitInput.Duration}
          unitSelector={['ms', 's']}
          type="number"
          tooltipId={tooltipIds.STATUS_TIME_PERIODICITY}
          fieldWidth="half"
          selectWidth="full"
        />
      </Form.FieldContainer>
      <Form.Field
        name="mac_settings.adr"
        component={Radio.Group}
        title={sharedMessages.adrAdaptiveDataRate}
        tooltipId={tooltipIds.ADR_USE}
        encode={encodeAdrMode}
        decode={decodeAdrMode}
      >
        <Radio label={sharedMessages.adrDynamic} value="dynamic" />
        <Radio label={sharedMessages.adrStatic} value="static" />
        <Radio label={sharedMessages.disabled} value="disabled" />
      </Form.Field>
      {isDynamicAdr && (
        <>
          <Form.Field
            title={sharedMessages.adrMargin}
            name="mac_settings.adr.dynamic.margin"
            component={Input}
            type="number"
            tooltipId={tooltipIds.ADR_MARGIN}
            min={-100}
            max={100}
            append="dB"
            fieldWidth="half"
          />
          <Form.Field
            label={sharedMessages.useDefaultNbTrans}
            name="mac_settings.adr.dynamic._use_default_nb_trans"
            component={Checkbox}
            tooltipId={tooltipIds.USE_DEFAULT_NB_TRANS}
          />
          {showEditNbTrans && (
            <>
              <Form.Field
                title={sharedMessages.adrNbTrans}
                name="mac_settings.adr.dynamic._override_nb_trans_defaults"
                component={Checkbox}
                label={sharedMessages.overrideNbTrans}
              />
              <Form.FieldContainer horizontal className="al-end mb-cs-xs">
                <Form.Field
                  title={sharedMessages.minNbTrans}
                  name="mac_settings.adr.dynamic.min_nb_trans"
                  component={Input}
                  type="number"
                  min={1}
                  max={3}
                  disabled={defaultNbTransDisabled}
                  className="d-flex direction-column"
                />
                <Form.Field
                  title={sharedMessages.maxNbTrans}
                  name="mac_settings.adr.dynamic.max_nb_trans"
                  component={Input}
                  type="number"
                  min={1}
                  max={3}
                  disabled={defaultNbTransDisabled}
                  className="d-flex direction-column"
                />
                <Message content={sharedMessages.defaultForAllRates} className="mt-cs-xl" />
              </Form.FieldContainer>
              {!defaultNbTransDisabled && (
                <div>
                  <Icon icon="info" nudgeUp className="mr-cs-xxs" />
                  <Message content={sharedMessages.defaultNbTransMessage} />
                </div>
              )}
              <Form.InfoField
                title={sharedMessages.specificOverrides}
                tooltipId={tooltipIds.DATA_RATE_SPECIFIC_OVERRIDES}
                className="mt-cs-m"
              >
                {adrOverrides &&
                  Object.keys(adrOverrides).map(index => (
                    <Form.FieldContainer horizontal className="al-end" key={index}>
                      <Form.Field
                        title={sharedMessages.dataRatePlaceholder}
                        name={`mac_settings.adr.dynamic.overrides.${index}._data_rate_index`}
                        valueSetter={dataRateValueSetter}
                        component={Select}
                        options={dataRateOverrideOptions}
                        className="d-flex direction-column flex-grow"
                        fieldWidth="quarter"
                      />
                      <Form.Field
                        title={sharedMessages.minNbTrans}
                        name={`mac_settings.adr.dynamic.overrides.${index}.min_nb_trans`}
                        component={Input}
                        className="d-flex direction-column flex-grow"
                        type="number"
                        min={1}
                        max={3}
                      />
                      <Form.Field
                        title={sharedMessages.maxNbTrans}
                        name={`mac_settings.adr.dynamic.overrides.${index}.max_nb_trans`}
                        component={Input}
                        className="d-flex direction-column flex-grow"
                        type="number"
                        min={1}
                        max={3}
                      />
                      <Button
                        type="button"
                        onClick={handleRemoveButtonClick}
                        icon={IconTrash}
                        message={sharedMessages.remove}
                        value={index}
                        secondary
                        danger
                      />
                    </Form.FieldContainer>
                  ))}
                <Button
                  type="button"
                  message={sharedMessages.addSpecificOverride}
                  onClick={addOverride}
                  icon={IconPlus}
                  secondary
                />
              </Form.InfoField>
            </>
          )}
        </>
      )}
      {isStaticAdr && (
        <>
          <Form.Field
            title={sharedMessages.adrDataRate}
            name="mac_settings.adr.static.data_rate_index"
            component={Input}
            type="number"
            inputWidth="xs"
            min={0}
          />
          <Form.Field
            title={sharedMessages.adrTransPower}
            name="mac_settings.adr.static.tx_power_index"
            component={Input}
            type="number"
            inputWidth="xs"
            max={15}
          />
          <Form.Field
            title={sharedMessages.adrUplinks}
            name="mac_settings.adr.static.nb_trans"
            component={Input}
            type="number"
            inputWidth="xs"
            min={1}
            max={15}
          />
        </>
      )}
      <Form.Field
        title={sharedMessages.desiredAdrAckLimit}
        name="mac_settings.desired_adr_ack_limit_exponent"
        component={Select}
        options={adrAckLimitOptions}
        tooltipId={tooltipIds.ADR_ACK_LIMIT}
        fieldWidth="half"
      />
      <Form.Field
        title={sharedMessages.desiredAdrAckDelay}
        name="mac_settings.desired_adr_ack_delay_exponent"
        component={Select}
        options={adrAckDelayOptions}
        tooltipId={tooltipIds.ADR_ACK_DELAY}
        fieldWidth="half"
      />
    </>
  )
}

MACSettingsProfileInnerForm.propTypes = {
  edit: PropTypes.bool,
}

MACSettingsProfileInnerForm.defaultProps = {
  edit: false,
}

const MACSettingsProfileForm = ({ edit, macSettingsProfile, macSettingsProfileId }) => {
  const dispatch = useDispatch()
  const { appId } = useParams()
  const { state } = useLocation()
  const navigate = useNavigate()
  const [error, setError] = useState('')

  const parsedInitialValues = useMemo(() => {
    if (!macSettingsProfile) {
      return initialValues
    }
    const normalizedInitialValues = {
      ...initialValues,
      ...macSettingsProfile,
      mac_settings: {
        ...initialValues.mac_settings,
        ...macSettingsProfile?.mac_settings,
        adr: Boolean(macSettingsProfile?.mac_settings?.adr?.dynamic)
          ? {
              dynamic: {
                ...initialValues.mac_settings.adr.dynamic,
                ...macSettingsProfile.mac_settings.adr.dynamic,
                min_nb_trans: macSettingsProfile.mac_settings?.adr?.dynamic?.min_nb_trans ?? null,
                max_nb_trans: macSettingsProfile.mac_settings?.adr?.dynamic?.max_nb_trans ?? null,
                _use_default_nb_trans:
                  !Boolean(macSettingsProfile.mac_settings?.adr?.dynamic?.min_nb_trans) &&
                  !Boolean(macSettingsProfile.mac_settings?.adr?.dynamic?.overrides),
                _override_nb_trans_defaults: Boolean(
                  macSettingsProfile.mac_settings?.adr?.dynamic?.min_nb_trans,
                ),
              },
            }
          : Boolean(macSettingsProfile?.mac_settings?.adr?.static)
            ? {
                ...initialValues.mac_settings.adr,
                ...macSettingsProfile.mac_settings.adr,
              }
            : {
                disabled: {},
              },
      },
    }
    return validationSchema.cast(normalizedInitialValues)
  }, [macSettingsProfile])

  const handleSubmit = useCallback(
    async (values, { setSubmitting }) => {
      const castedValues = validationSchema.cast(values)
      try {
        await dispatch(attachPromise(createMacSettingsProfile(appId, castedValues)))
        toast({
          message: m.created,
          type: toast.types.SUCCESS,
        })
        if (state?.deviceId) {
          navigate(`/applications/${appId}/devices/${state.deviceId}/general-settings`, {
            preventScrollReset: true,
          })
        } else {
          navigate(`/applications/${appId}/mac-settings-profiles`)
        }
      } catch (error) {
        setSubmitting(false)
        setError(error)
      }
    },
    [appId, dispatch, navigate, state],
  )

  const handleEdit = useCallback(
    async (_, { setSubmitting }, cleanedValues) => {
      const profileDiff = diff(macSettingsProfile, cleanedValues)
      try {
        if (!isEmpty(profileDiff)) {
          profileDiff.ids = {
            application_ids: { application_id: appId },
            profile_id: macSettingsProfileId,
          }
          if (profileDiff.mac_settings?.adr?.dynamic) {
            const cleanAdr = omitBy(profileDiff.mac_settings?.adr?.dynamic, (_, key) =>
              key.startsWith('_'),
            )
            profileDiff.mac_settings.adr.dynamic = cleanAdr
          }

          await dispatch(
            attachPromise(updateMacSettingsProfile(appId, macSettingsProfileId, profileDiff)),
          )
        }
        toast({
          message: m.updated,
          type: toast.types.SUCCESS,
        })
      } catch (error) {
        setSubmitting(false)
        setError(error)
      }
    },
    [appId, dispatch, macSettingsProfile, macSettingsProfileId],
  )

  return (
    <Form
      validationSchema={validationSchema}
      initialValues={parsedInitialValues}
      onSubmit={edit ? handleEdit : handleSubmit}
      error={error}
    >
      <MACSettingsProfileInnerForm edit={edit} />
      <SubmitBar>
        <Form.Submit
          component={SubmitButton}
          message={edit ? sharedMessages.saveChanges : sharedMessages.createMacSettingsProfile}
        />
      </SubmitBar>
    </Form>
  )
}

MACSettingsProfileForm.propTypes = {
  edit: PropTypes.bool,
  macSettingsProfile: PropTypes.shape({
    ids: PropTypes.shape({}),
    mac_settings: PropTypes.shape({
      adr: PropTypes.shape({
        dynamic: PropTypes.shape({
          min_nb_trans: PropTypes.number,
          max_nb_trans: PropTypes.number,
          overrides: PropTypes.shape({}),
        }),
        static: PropTypes.shape({}),
      }),
    }),
  }),
  macSettingsProfileId: PropTypes.string,
}

MACSettingsProfileForm.defaultProps = {
  edit: false,
  macSettingsProfile: undefined,
  macSettingsProfileId: undefined,
}

export default MACSettingsProfileForm
